package com.gome.ocean.service.datax.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.gome.ocean.dao.datax.IWebSqlChildrenDAO;
import com.gome.ocean.dao.datax.IWebSqlDAO;
import com.gome.ocean.dao.model.datax.SqlChildrenNode;
import com.gome.ocean.dao.model.datax.SqlParentNode;
import com.gome.ocean.dao.model.datax.SqlTplMenuVO;
import com.gome.ocean.service.datax.IWebSqlService;

/**
 * @author zhangguoqing 2016年9月18日 下午4:22:08
 * @since 5.0.0
 */
@Service("adwebSqlServiceImpl")
public class WebSqlServiceImpl implements IWebSqlService {

	@Autowired
	private IWebSqlDAO webSqlDao;
	@Autowired
	private IWebSqlChildrenDAO sqlChildrenDao;

	@Override
	public void insertSqlParentModule(SqlParentNode node) {
		try {
			webSqlDao.insertSqlParentModule(node);
		} catch (Exception e) {
			e.printStackTrace();
		}
	} 

	@Override
	public void insertSqlChildrenModule(SqlChildrenNode node) {
		try {
			sqlChildrenDao.insertSqlChildrenModule(node);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	@Override
	public void deleteSqlParentModuleById(Integer id) {
		try {
			webSqlDao.deleteSqlParentModuleById(id);
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

	@Override
	public void deleteSqlChildrenModuleByParentId(Integer parentId) {
		try {
			sqlChildrenDao.deleteSqlChildrenModuleByParentId(parentId);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	@Override
	public void deleteSqlChildrenModuleById(Integer id) {
		try {
			sqlChildrenDao.deleteSqlChildrenModuleById(id);
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

	@Override
	public void updateSqlParentModuleNode(SqlParentNode node) {
		try {
			webSqlDao.updateSqlParentModuleNode(node);
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

	@Override
	public void updateSqlChildrenModuleNode(SqlChildrenNode node) {
		try {
			sqlChildrenDao.updateSqlChildrenModuleNode(node);
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

	@Override
	public SqlParentNode getSqlParentNode(Integer id) {
		try {
			SqlParentNode node = webSqlDao.getSqlParentNode(id);
			if (node != null) {
				return node;
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

	@Override
	public List<SqlParentNode> getSqlParentNodeList(Map<String, Object> map) {
		try {
			List<SqlParentNode> list = webSqlDao.getSqlParentNodeList(map);
			if (list != null && list.size() > 0) {
				return list;
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

	@Override
	public SqlChildrenNode getSqlChildrenNode(Integer id) {
		try {
			SqlChildrenNode node = sqlChildrenDao.getSqlChildrenNode(id);
			if (node != null) {
				return node;
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

	@Override
	public List<SqlChildrenNode> getSqlChildrenNodeList(Map<String, Object> map) {
		try {
			List<SqlChildrenNode> list = sqlChildrenDao.getSqlChildrenNodeList(map);
			if (list != null && list.size() > 0) {
				return list;
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

	@Override
	public List<SqlTplMenuVO> getSqlTplMenuVO(Map<String, Object> param) {
		try {
			List<SqlTplMenuVO> sqlTplMenuVOs = sqlChildrenDao.getSqlTplMenuVO(param);
			return sqlTplMenuVOs;
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return null;
		}
	}

	@Override
	public boolean insertSelective(SqlTplMenuVO sqlTplMenuVO) {
		
		try {
			sqlChildrenDao.insertSelective(sqlTplMenuVO);
			return true;
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return false;
		}
	}

	@Override
	public boolean updateByPrimaryKeySelective(SqlTplMenuVO sqlTplMenuVO) {
		try {
			sqlChildrenDao.updateByPrimaryKeySelective(sqlTplMenuVO);
			return true;
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return false;
		}
	}

	@Override
	public boolean deleteByPrimaryKey(Long id) {
		try {
			sqlChildrenDao.deleteByPrimaryKey(id);
			return true;
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return false;
		}}

	@Override
	public List<SqlTplMenuVO> getSqlTplMenuVOCollection(Map<String, Object> param) {
		try {
			List<SqlTplMenuVO> sqlTplMenuVOs = sqlChildrenDao.getSqlTplMenuVOCollection(param);
			return sqlTplMenuVOs;
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return null;
		}
	}

}
